Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug where some requests pass variables = {} instead of variables undefined #714

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ian
Copy link

@ian ian commented Jan 31, 2022

I'm seeing an issue with fastify + mercurius where some GraphQL playgrounds / queries are getting parsed as variables = {} instead of the expected variables = undefined

Versions:

fastify 3.25.3
mercurius 9.1.0

This is most easily seen when using GraphQL Playground vs Insomnia:

Insomnia:

before buildExecutionContext {
  document: {
    kind: 'Document',
    definitions: [ [Object] ],
    loc: { start: 0, end: 46 }
  },
  variables: undefined,
  shouldCompileJit: undefined
}

vs GQL Playground (or Altair)

before buildExecutionContext {
  document: {
    kind: 'Document',
    definitions: [ [Object], [Object], [Object], [Object] ],
    loc: { start: 0, end: 1305 }
  },
  variables: {},
  shouldCompileJit: false
}

Notice the variable values are different. There's no difference in fastify implementation, just a difference with clients.

The difference in variables value is causing mercurius to blow up on document not being set inside buildExecutionContext

Copy link
Collaborator

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a unit test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants